//
//  SC_TabBarController.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/12.
//  Copyright © 2016年 Gcx. All rights reserved.
//
#define COLOR(R, G, B, A)  [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define colordbdbdb [UIColor colorWithRed:219.0/255 green:219.0/255 blue:219.0/255 alpha:1.0f]
#define SIZEWIDTH   [[UIScreen mainScreen] bounds].size.width
#define SIZEHEIGHT  [[UIScreen mainScreen] bounds].size.height

#import "SC_TabBarController.h"


#import "SCModuleManager.h"


#import "SC_NavigationController.h"

@interface SC_TabBarController ()

@end

@implementation SC_TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupViewControllers];

}

- (void)setupViewControllers{
    
    UIView *tabView  = [[UIView alloc]initWithFrame:self.tabBar.bounds];
    tabView.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:tabView atIndex:0];
    self.tabBar.opaque = YES;
    
    SC_ChildViewController *schooleVC = [SCModuleManager SCModuleManagerInitWithName:@"SchoolViewController"];
   
    SC_NavigationController *schooleNC = [[SC_NavigationController alloc]initWithRootViewController:schooleVC];
    
      SC_ChildViewController *findVC = [SCModuleManager SCModuleManagerInitWithName:@"FindViewController"];
   
    SC_NavigationController *findNC = [[SC_NavigationController alloc]initWithRootViewController:findVC];

     SC_ChildViewController *meVC = [SCModuleManager SCModuleManagerInitWithName:@"MeViewController"];
   
    SC_NavigationController *meNC = [[SC_NavigationController alloc]initWithRootViewController:meVC];
    
    [ self setTabBarItem:schooleNC andTitle:@"首页" andNormalImage:@"校内" andSelectedImage:@"校内2"];
    [ self setTabBarItem:findNC andTitle:@"发现" andNormalImage:@"发现" andSelectedImage:@"发现2"];
    [ self setTabBarItem:meNC andTitle:@"我的" andNormalImage:@"我的" andSelectedImage:@"我的2"];
    
    self.viewControllers = @[schooleNC,findNC,meNC];
    
    self.tabBar.tintColor = COLOR(36, 112, 222, 1.0);
    self.tabBar.backgroundColor = [UIColor whiteColor];
    self.delegate = self;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SIZEWIDTH, 0.5)];
    view.backgroundColor = colordbdbdb;
    [tabView addSubview:view];
    
    
    
}
//设置tabBarItem
-(void)setTabBarItem:(UIViewController*)viewC andTitle:(NSString*)title andNormalImage:(NSString *)normalImage andSelectedImage:(NSString*)selectedImage{
    
    UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:title image:[[UIImage imageNamed:normalImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
    //设置title的位置
    [item setImageInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    //设置title的位置
    [item setTitlePositionAdjustment:UIOffsetMake(0, 0)];
    
    viewC.tabBarItem = item;
}

@end
